package com.chtw.oasystem.common.changelogs;

import com.chtw.oasystem.bean.*;
import com.chtw.oasystem.utils.Methods;
import com.chtw.oasystem.utils.TimeUtils;

import java.util.Date;

/**
 * @author chtw
 * @date 2020-11-17 22:12
 */
public class ChangeLogsUtils {

    public static ChangeLogs generateFileChangelog(FullUserInfo user, String filename){
        return new ChangeLogs(null,
                user.getUserName(),
                TimeUtils.formatDate(new Date(), null),
                "上传文件" + filename,
                Methods.getMethodName(),
                Records.class.getName()
                );
    }

    public static ChangeLogs generateUsersChangeLog(String opUser, String opedUser, String op){
        return new ChangeLogs(null,
                opUser,
                TimeUtils.formatDate(new Date(), null),
                op + "用户：" + opedUser,
                Methods.getMethodName(),
                Users.class.getName()
        );
    }

    public static ChangeLogs generateRoleChangeLog(String opUser, String roleName, String op){
        return new ChangeLogs(null,
                opUser,
                TimeUtils.formatDate(new Date(), null),
                op + roleName + "角色",
                Methods.getMethodName(),
                Role.class.getName()
        );
    }

    public static ChangeLogs generateDeptChangeLog(String opUser, String deptName, String op){
        return new ChangeLogs(null,
                opUser,
                TimeUtils.formatDate(new Date(), null),
                op + deptName + "部门",
                Methods.getMethodName(),
                Depts.class.getName()
        );
    }

    public static ChangeLogs generateSocialSecurityChangeLog(String opUser, String target, String op){
        return new ChangeLogs(null,
                opUser,
                TimeUtils.formatDate(new Date(), null),
                op + target + "的社保信息",
                Methods.getMethodName(),
                SocialSecurity.class.getName()
        );
    }
    public static ChangeLogs generatePositionChangeLog(String opUser, String target, String op){
        return new ChangeLogs(null,
                opUser,
                TimeUtils.formatDate(new Date(), null),
                op + target + "岗位",
                Methods.getMethodName(),
                Position.class.getName()
        );
    }

    public static ChangeLogs generateTrainChangeLog(String opUser, String target, String op){
        return new ChangeLogs(null,
                opUser,
                TimeUtils.formatDate(new Date(), null),
                op + target + "培训",
                Methods.getMethodName(),
                Train.class.getName()
        );
    }

    public static ChangeLogs generateFileUploadChangeLog(String opUser, String target, String op){
        return new ChangeLogs(null,
                opUser,
                TimeUtils.formatDate(new Date(), null),
                op + target + "文件",
                Methods.getMethodName(),
                Train.class.getName()
        );
    }

    public static ChangeLogs generateApproveChangeLog(String opUser, String target, String op){
        return new ChangeLogs(null,
                opUser,
                TimeUtils.formatDate(new Date(), null),
                op + target + "审批",
                Methods.getMethodName(),
                Train.class.getName()
        );
    }
}
